package com.project.poetry.common.constant;

/**
 * 枚举
 * @author mengxj
 */
public enum ConstantEnum {

    /**
     * 成功
     */
    SUCCESS(200, "OK"),

    /**
     * 失败
     */
    FAILED(ConstantValue.UNKNOWN_ERROR_STATUS_CODE, "未知错误！！！"),

    /**
     * 自定义枚举常量
     */
    SERVICE_CONSTANT,

    /**
     * 未知异常的状态码
     */
    SERVICE_ERROR(ConstantValue.UNKNOWN_ERROR_STATUS_CODE);

    Integer code;

    String message;

    ConstantEnum(){}

    ConstantEnum(Integer code){
        this.code = code;
    }

    ConstantEnum(Integer code, String message){
        this.code = code;
        this.message = message;
    }

    public String getMessage() {
        return message;
    }

    public Integer getCode() {
        return code;
    }

    public ConstantEnum setCode(int code) {
        this.code = code;
        return this;
    }

    public ConstantEnum setMessage(String message) {
        this.message = message;
        return this;
    }

    public static ConstantEnum errMessage(String message){
        return SERVICE_ERROR.setMessage(message);
    }

    public static ConstantEnum newConstant(int code, String message){
        return SERVICE_CONSTANT.setCode(code).setMessage(message);
    }
}
